package main

import "fmt"

func main() {
	var arr [3]int
	arr[0] = 1
	arr[1] = 2
	arr[2] = 3
	fmt.Println(arr)

	var arr01 [3]int = [3]int{1, 2, 3}
	fmt.Println(arr01)

	arr02 := [3]int{1, 2, 3}
	fmt.Println(arr02)

	arr03 := [...]int{1, 2, 3}
	fmt.Println(arr03)

	arr04 := [...]int{1, 2, 3}
	arr05 := [...]int{1, 2, 3, 4}
	fmt.Printf("%d的类型是: %T\n", arr04, arr04)
	fmt.Printf("%d的类型是: %T\n", arr05, arr05)

	type arr3 [3]int
	arr06 := arr3{1, 2, 3}
	fmt.Printf("%d的类型是: %T\n", arr06, arr06)

	arr07 := [4]int{2: 3}
	fmt.Println(arr07)

	arr08 := [...]int{1, 2, 3}
	fmt.Printf("%d的类型是: %T\n", arr08[0:2], arr08[0:2])

	arr09 := [5]int{1, 2, 3, 4, 5}
	list01 := arr09[1:3]
	list02 := arr09[1:3:4]
	fmt.Println(list01, list02)

	fmt.Printf("myarr长度为%d, 容量为: %d\n", len(arr09), cap(arr09))
	list03 := arr09[1:3]
	fmt.Printf("list03的长度为: %d, 容量为: %d\n", len(list03), cap(list03))
	fmt.Println(list03)
	list04 := arr09[1:3:4]
	fmt.Printf("list04的长度为: %d, 容量为: %d\n", len(list04), cap(list04))
	fmt.Println(list03)

	var strList []string
	var numList []int
	var numListEmpty = []int{}
	fmt.Println(strList, numList, numListEmpty)

	a := make([]int, 2)
	b := make([]int, 2, 10)
	fmt.Println(a, b)
	fmt.Println(len(a), len(b))
	fmt.Println(cap(a), cap(b))

	a1 := []int{4: 2}
	fmt.Println(a1)
	fmt.Println(len(a1), cap(a1))

	var list05 []int
	fmt.Println(list05 == nil)

	myarr := []int{1}
	myarr = append(myarr, 2)
	myarr = append(myarr, 3, 4)
	myarr = append(myarr, []int{7, 8}...)
	myarr = append([]int{0}, myarr...)
	myarr = append(myarr[:5], append([]int{5, 6}, myarr[5:]...)...)
	fmt.Println(myarr)

	var numbers4 = [...]int{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
	myslice := numbers4[4:6:8]
	fmt.Printf("myslice为%d, 其长度为: %d\n", myslice, len(myslice))
	myslice = myslice[:cap(myslice)]
	fmt.Printf("myslice的第四个元素为: %d", myslice[3])
}
